use sea_orm::prelude::*;
use crate::entity::prelude::*;

use crate::database::initialize_static;
use crate::entity::authority_user;
use crate::entity::authority_user::Model;

pub async fn query_user_from_username(username: &str) -> anyhow::Result<Option<Model>> {
    let db = initialize_static().await;
    let users = AuthorityUser::find().filter(
        authority_user::Column::LoginName.eq(username)
    ).one(db).await?;

    tracing::info!("users = {:?}", users);

    Ok(users)
}